<?php
if (!defined('BASEPATH')) {
	exit('No direct script access allowed');
}

if (!function_exists('profile_menu')) {
	function profile_menu() {
		$CI = &get_instance();
		$CI->load->database();

		$sql = 'SELECT * FROM profil';
		$CI->db->cache_on();
		$query = $CI->db->query($sql)->result_array();
		foreach ($query as $kolom) {
			echo '<li><a href="' .site_url('profile/' . $kolom['slug']). '" title="' .$kolom['judul']. '">' . $kolom['judul'] . '</a></li>';
		}
	}
}

if (!function_exists('services_menu')) {
	function services_menu() {
		$CI = &get_instance();
		$CI->load->database();

		$sql = 'SELECT * FROM layanan';
		$CI->db->cache_on();
		$query = $CI->db->query($sql)->result_array();
		foreach ($query as $kolom) {
			echo '<li><a href="' .site_url('services/' . $kolom['slug']). '" title="' .$kolom['layanan']. '">' . $kolom['layanan'] . '</a></li>';
		}
	}
}

if (!function_exists('list_berita')) {
	function list_berita() {
		$CI = &get_instance();
		$CI->load->database();

		$sql = 'SELECT * FROM berita';
		$CI->db->cache_on();
		$query = $CI->db->query($sql)->result_array();
		foreach ($query as $kolom) {
			echo '<li><a href="' .site_url('news/' . $kolom['slug']). '" title="' .$kolom['judul']. '">' . $kolom['judul'] . '</a></li>';
		}
	}
}

if (!function_exists('list_schedules')) {
	function list_schedules() {
		$CI = &get_instance();
		$CI->load->database();

		$sql = 'SELECT * FROM jadwal';
		$CI->db->cache_on();
		$query = $CI->db->query($sql)->result_array();
		foreach ($query as $kolom) {
			echo '<li><a href="' .site_url('schedules/' . $kolom['slug']). '" title="' .$kolom['nama_kegiatan']. '">' . $kolom['nama_kegiatan'] . '</a></li>';
		}
	}
}

if (!function_exists('list_schedules_f')) {
	function list_schedules_f() {
		$CI = &get_instance();
		$CI->load->database();
		$CI->load->helper('id_date');

		$sql = 'SELECT * FROM jadwal';
		$CI->db->cache_on();
		$query = $CI->db->query($sql)->result_array();
		foreach ($query as $kolom) {
			echo '<li>
        <a href="' .site_url('schedules/' . $kolom['slug']). '" title="' .$kolom['nama_kegiatan']. '">' . $kolom['nama_kegiatan'] . '</a>
        <p class="wkt-schedules-footer"><i class="fa fa-calendar fa-fw"></i>&nbsp;' . id_date($kolom['tgl_mulai']) . ' - ' . id_date($kolom['tgl_selesai']) . '</p>
      </li>';
		}
	}
}

if (!function_exists('alamat_kantor')) {
	function alamat_kantor() {
		$CI = &get_instance();
		$CI->load->database();

		$sql = 'SELECT alamat FROM kontak';
		$CI->db->cache_on();
		$query = $CI->db->query($sql)->row_array();
		return $query['alamat'];
	}
}

if (!function_exists('phone')) {
	function phone() {
		$CI = &get_instance();
		$CI->load->database();

		$sql = 'SELECT phone FROM kontak';
		$CI->db->cache_on();
		$query = $CI->db->query($sql)->row_array();
		return $query['phone'];
	}
}

if (!function_exists('email')) {
	function email() {
		$CI = &get_instance();
		$CI->load->database();

		$sql = 'SELECT email FROM kontak';
		$CI->db->cache_on();
		$query = $CI->db->query($sql)->row_array();
		return $query['email'];
	}
}

if (!function_exists('fb')) {
	function fb() {
		$CI = &get_instance();
		$CI->load->database();

		$sql = 'SELECT url FROM social WHERE id_social = 1';
		$CI->db->cache_on();
		$query = $CI->db->query($sql)->row_array();

		if(empty($query['url'])){
			$url = '#';
		}else{
			$url = $query['url'];
		}
		return $url;
	}
}

if (!function_exists('tw')) {
	function tw() {
		$CI = &get_instance();
		$CI->load->database();

		$sql = 'SELECT url FROM social WHERE id_social = 2';
		$CI->db->cache_on();
		$query = $CI->db->query($sql)->row_array();
		
		if(empty($query['url'])){
			$url = '#';
		}else{
			$url = $query['url'];
		}
		return $url;
	}
}

if (!function_exists('gp')) {
	function gp() {
		$CI = &get_instance();
		$CI->load->database();

		$sql = 'SELECT url FROM social WHERE id_social = 3';
		$CI->db->cache_on();
		$query = $CI->db->query($sql)->row_array();
		
		if(empty($query['url'])){
			$url = '#';
		}else{
			$url = $query['url'];
		}
		return $url;
	}
}

if (!function_exists('online_support')) {
	function online_support() {
		$CI = &get_instance();
		$CI->load->database();

		$sql = 'SELECT * FROM online_support';
		$CI->db->cache_on();
		$query = $CI->db->query($sql)->result_array();
		foreach ($query as $kolom) {
			?>
				<p class="text-center" style="margin-bottom:5px;">
          <a href="ymsgr:sendIM?<?php echo $kolom['username']; ?>">
            <img src="http://opi.yahoo.com/online?u=<?php echo $kolom['username']; ?>&amp;m=g&amp;t=2&amp;l=us"/>
            <h5 style="margin:0 0 0 5px; color: #fff; font-size: 12px;"><?php echo $kolom['nama']; ?></h5>
          </a>
        </p>
      <?php
		}
	}
}

if (!function_exists('online_support_footer')) {
	function online_support_footer() {
		$CI = &get_instance();
		$CI->load->database();

		$sql = 'SELECT * FROM online_support';
		$CI->db->cache_on();
		$query = $CI->db->query($sql)->result_array();
		foreach ($query as $kolom) {
			?>
		<p>
                <a href="ymsgr:sendIM?<?php echo $kolom['username']; ?>">
                  <img src="http://opi.yahoo.com/online?u=<?php echo $kolom['username']; ?>&amp;m=g&amp;t=2&amp;l=us"/>
                  <span style="margin:0 0 0 5px; color: #fff; font-size: 12px;"><?php echo $kolom['nama']; ?></span>
                </a>
              </p>
              
              <?php
		}
	}
}